package com.example.kotlin.jetpack_compose_by_tutorials

import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import com.example.myapplication.R

/**
 *Create by Fanketly on 2022/9/15
 *Gitee:https://gitee.com/fanketly
 *desc:展示常用属性
 *
 *更多Button:  IconButton(onClick = { /*TODO*/ }) {
 *
 *}
 *OutlinedButton(onClick = { /*TODO*/ }) {
 *
 *}
 *IconToggleButton(checked =, onCheckedChange =) {
 *
 *}
 *TextButton(onClick = { /*TODO*/ }) {
 *
 *}
 **/

@Composable
fun MyButton() {

    Button(
        onClick = { },
        enabled = true,
        shape = MaterialTheme.shapes.small,
        elevation = ButtonDefaults.elevation(),
        border = BorderStroke(1.dp, colorResource(id = R.color.teal_200))
    ) {
        Text(text = "AA", color = Color.White)
    }
}

@Composable
fun MyRadioButtonGroup() {
    val list = listOf("A", "B", "C")
    val selected = remember {
        mutableStateOf(list.first())
    }
    Column {
        list.forEach {
            val isSelected = it == selected.value
            val colors = RadioButtonDefaults.colors( // 4
                selectedColor = colorResource(
                    id =
                    R.color.teal_200
                ),
                unselectedColor = colorResource(
                    id =
                    R.color.grey
                ),
                disabledColor = Color.LightGray
            )
            RadioButton(colors = colors, selected = isSelected, onClick = {
                selected.value = it
            }, interactionSource = remember { MutableInteractionSource() })
        }
    }
}

@Composable
fun MyFloatActionButton() {
    FloatingActionButton(
        onClick = {},
        backgroundColor = colorResource(
            id = R.color.teal_200
        ),
        contentColor = Color.White,
        content = {
            Icon(
                Icons.Filled.Favorite, contentDescription = "Test FAB"
            )
        }
    )
}